<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vue中同时使用过渡和动画</title>
  <link rel="stylesheet" href="../asset/css/animate.css">
  <script src="../asset/js/vue.js"></script>
  <style>
    .fade-enter,
    .fade-leave-to {
      opacity: 0;
    }

    .fade-leave-active,
    .fade-enter-active {
      transition: opacity 1s;
    }
  </style>
</head>

<body>
  <div id="root">
    <!-- 使用 type 特性并设置 animation 或 transition 来明确声明你需要 Vue 监听的类型 -->
    <!-- <transition type='transition' name='fade' enter-active-class='animated swing fade-enter-active' leave-active-class='animated shake fade-leave-active'
      appear appear-active-class='animated swing'>
      <div v-if='show'>Hello World</div>
    </transition> -->
    <!-- 使用 duration 属性定制一个显性的过渡持续时间 (以毫秒计) -->
    <transition :duration='{
      enter:5000,
      leave:10000
    }' name='fade' enter-active-class='animated swing fade-enter-active' leave-active-class='animated shake fade-leave-active'
      appear appear-active-class='animated swing'>
      <div v-if='show'>Hello World</div>
    </transition>
    <button @click='handleClick'>切换</button>
  </div>
  <script>
    let vm = new Vue({
      el: '#root',
      data: {
        show: true
      },
      methods: {
        handleClick() {
          this.show = !this.show
        }
      }
    })
  </script>
</body>

</html>